SUPPORT / SAMPLES & SAS NOTES
 

Support

Problem Note 62844: The LENGTHN function returns incorrect results when used within %SYSFUNC in SAS® 9.4M5 (TS1M5)

DetailsAboutRate It

The LENGTHN function returns incorrect results when you use it within %SYSFUNC in the fifth maintenance release of SAS 9.4 (TS1M5).  The function should return a length of 0 if the value of the argument is blank. However, a length greater than 0 is being returned. This problem does not occur when you use the LENGTHN function in the DATA step.

An example of the incorrect behavior is shown in the example SAS® log output below. The LENGTHN function incorrectly returns a value of 2 when used within %SYSFUNC.

92 %let x=%sysfunc(lengthn(%str( )));
93 %put &=x;
X=2
94
95 data _null_;
96 x = lengthn(" ");
97 put x=;
98 run;
x=0

NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

To circumvent the problem, use CALL SYMPUTX to create a macro variable instead of a %LET statement.  For example:

data _null_;
   call symputx('x',lengthn("  "));
run;

This issue was fixed in SAS 9.4, Rev. 940_18w30.



Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemBase SASLinux for x649.4 TS1M59.4 TS1M5
HP-UX IPF9.4 TS1M59.4 TS1M5
64-bit Enabled Solaris9.4 TS1M59.4 TS1M5
64-bit Enabled AIX9.4 TS1M59.4 TS1M5
Windows 7 Ultimate x649.4 TS1M59.4 TS1M5
Windows 7 Ultimate 32 bit9.4 TS1M59.4 TS1M5
Windows 7 Enterprise x649.4 TS1M59.4 TS1M5
Microsoft Windows Server 20169.4 TS1M59.4 TS1M5
Microsoft Windows Server 2012 Std9.4 TS1M59.4 TS1M5
Microsoft Windows Server 2012 R2 Std9.4 TS1M59.4 TS1M5
Microsoft Windows Server 2012 R2 Datacenter9.4 TS1M59.4 TS1M5
Microsoft Windows Server 2012 Datacenter9.4 TS1M59.4 TS1M5
Microsoft Windows Server 2008 for x649.4 TS1M59.4 TS1M5
Microsoft Windows Server 2008 R29.4 TS1M59.4 TS1M5
Microsoft Windows Server 20089.4 TS1M59.4 TS1M5
Microsoft Windows 109.4 TS1M59.4 TS1M5
Microsoft Windows 8.1 Pro x649.4 TS1M59.4 TS1M5
Microsoft Windows 8.1 Pro 32-bit9.4 TS1M59.4 TS1M5
Microsoft Windows 8.1 Enterprise x649.4 TS1M59.4 TS1M5
Microsoft Windows 8.1 Enterprise 32-bit9.4 TS1M59.4 TS1M5
Microsoft Windows 8 Pro x649.4 TS1M59.4 TS1M5
Microsoft Windows 8 Pro 32-bit9.4 TS1M59.4 TS1M5
Microsoft Windows 8 Enterprise x649.4 TS1M59.4 TS1M5
Microsoft Windows 8 Enterprise 32-bit9.4 TS1M59.4 TS1M5
Microsoft® Windows® for x649.4 TS1M59.4 TS1M5
z/OS 64-bit9.4 TS1M59.4 TS1M5
Solaris for x649.4 TS1M59.4 TS1M5
Windows 7 Professional x649.4 TS1M59.4 TS1M5
Windows 7 Professional 32 bit9.4 TS1M59.4 TS1M5
Windows 7 Home Premium x649.4 TS1M59.4 TS1M5
Windows 7 Home Premium 32 bit9.4 TS1M59.4 TS1M5
z/OS9.4 TS1M59.4 TS1M5
Windows 7 Enterprise 32 bit9.4 TS1M59.4 TS1M5
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.